package com.agent.util;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

/**
 * Created by hg on 2019/1/7.
 */
//@PropertySource(value = "classpath:config/config.properties")
//@Component
public class MyPropertiesConfigurer extends PropertyPlaceholderConfigurer {
    public static Map<String,String> ctxPropertiesMap =new HashMap<>();
    @Override
    protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties props) throws BeansException {
        super.processProperties(beanFactoryToProcess, props);
        props.entrySet().forEach(entry ->{
            ctxPropertiesMap.put(entry.getKey().toString(),entry.getValue().toString().trim());
        });
    }
}
